package org.lk.controller;

import cn.hutool.core.util.IdUtil;
import org.lk.entity.UserLogin;
import org.lk.util.ResponseResult;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * @author: lk
 * @since:
 */
@RestController
@RequestMapping("/users")
public class UserController {

    @PostMapping("login")
    public ResponseResult login(@RequestBody UserLogin userLogin) {
        if (userLogin.getUsername() == null) {
            return ResponseResult.fail("用户名称不能为空");
        }
        if (userLogin.getPassword() == null) {
            return ResponseResult.fail("密码不能为空");
        }
        String token = IdUtil.fastSimpleUUID();
        Map<String,Object> map=new HashMap<>();
        map.put("token",token);
        return ResponseResult.success(map);
    }
    @GetMapping("info")
    public ResponseResult info() {

        Map<String,Object> map=new HashMap<>();
        map.put("username","admin");
        map.put("roles", Arrays.asList("admin"));
        return ResponseResult.success(map);
    }
}
